package dao

import (
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

// 全局变量声明
var (
	DB *gorm.DB
)

// 数据库初始化连接
func InitMySQL()(err error)  {
	dsn := "root:@(127.0.0.1:3306)/state_of_an_illness?charset=utf8&parseTime=True&loc=Local"
	DB, err = gorm.Open("mysql", dsn)
	if err != nil {
		return
	}
	return DB.DB().Ping()
}

func Close(){
	DB.Close()
}